<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: absolute;
            left: 0;
            width: 150px;
            height: 150px;
            background-color: brown;
        }
    </style>
</head>
<body>
    
    <div></div>
    <script>
        /*
          
            touchstart：盒子的当前坐标，鼠标的起始坐标
            touchmove：鼠标的移动时坐标。鼠标的移动距离，移动盒子
            touchend

            touches 
            targetTouches
            changedTouches
            某个触点：touches[0]
            坐标：touches[0].pageX
            目标拖动元素：
                目标位置 = 当前位置 + 移动的距离  无解
                目标位置 = 原来的位置 + 移动的距离
                移动的距离 = 鼠标的移动距离
        */
        var div = document.querySelector('div');
        var divX = 0; // 盒子起始坐标
        var divY = 0;
        var mouseX = 0;  // 鼠标的起始坐标
        var mouseY = 0;  
        div.addEventListener('touchstart',function(e){
            var x = e.targetTouches[0].pageX;
            var y = e.targetTouches[0].pageY;
            mouseX = x;
            mouseY = y;
            divX = div.offsetLeft;
            divY = div.offsetTop;
        });
        div.addEventListener('touchmove',function(e){
            var x = e.targetTouches[0].pageX;
            var y = e.targetTouches[0].pageY;
            // 鼠标移动的速度
            var moveX = Y - mouseX;
            var moveY = x - mousey; 
            div.style.left = divX + moveX+ 'px';
            div.style.top = divY + moveY+ 'px';
            console.log("move-----"+x);
        });

           /* 
            时间 鼠标坐标
            0      0,0
            1      1,0
            2      2,0
            3      3,0
            4      4,0
            5      5,0
        
        */
    </script>
</body>
</html>